package com.ruoyi.read.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.read.domain.SysNoticeRead;
import com.ruoyi.read.service.ISysNoticeReadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * readController
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/rea/read")
public class SysNoticeReadController extends BaseController
{
    @Autowired
    private ISysNoticeReadService sysNoticeReadService;

    /**
     * 查询read列表
     */
    @PreAuthorize("@ss.hasPermi('rea:read:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysNoticeRead sysNoticeRead)
    {
        startPage();
        List<SysNoticeRead> list = sysNoticeReadService.selectSysNoticeReadList(sysNoticeRead);
        return getDataTable(list);
    }

    /**
     * 导出read列表
     */
    @PreAuthorize("@ss.hasPermi('rea:read:export')")
    @Log(title = "read", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysNoticeRead sysNoticeRead)
    {
        List<SysNoticeRead> list = sysNoticeReadService.selectSysNoticeReadList(sysNoticeRead);
        ExcelUtil<SysNoticeRead> util = new ExcelUtil<SysNoticeRead>(SysNoticeRead.class);
        return util.exportExcel(list, "read数据");
    }

    /**
     * 获取read详细信息
     */
    @PreAuthorize("@ss.hasPermi('rea:read:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sysNoticeReadService.selectSysNoticeReadById(id));
    }

    /**
     * 新增read
     */
//    @PreAuthorize("@ss.hasPermi('rea:read:add')")
    @Log(title = "read", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysNoticeRead sysNoticeRead)
    {
        return toAjax(sysNoticeReadService.insertSysNoticeRead(sysNoticeRead));
    }

    /**
     * 修改read
     */
//    @PreAuthorize("@ss.hasPermi('rea:read:edit')")
    @Log(title = "read", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysNoticeRead sysNoticeRead)
    {
        return toAjax(sysNoticeReadService.updateSysNoticeRead(sysNoticeRead));
    }

    /**
     * 删除read
     */
    @PreAuthorize("@ss.hasPermi('rea:read:remove')")
    @Log(title = "read", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysNoticeReadService.deleteSysNoticeReadByIds(ids));
    }
}
